//
//  SJReportView.m
//  WSL
//
//  Created by CJ on 2018/2/5.
//  Copyright © 2018年 sanjuetech. All rights reserved.
//

#import "SJReportView.h"

@interface SJReportView ()

@property (strong, nonatomic) UIView *containView;
@property (strong, nonatomic) UIButton *buttonItem_0;
@property (strong, nonatomic) UIButton *buttonItem_1;
@property (strong, nonatomic) UIButton *buttonItem_2;
@property (strong, nonatomic) UIButton *buttonItem_3;

@property (strong, nonatomic) UIButton *buttonItem_4;


@end

@implementation SJReportView


- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
    [self addSubview:self.containView];
    self.containView.sd_layout.spaceToSuperView(UIEdgeInsetsZero);
    
    [self.containView addSubview:self.buttonItem_0];
    self.buttonItem_0.sd_layout
    .topSpaceToView(self.containView, SJLayoutFrame(0))
    .leftSpaceToView(self.containView, SJLayoutFrame(0))
    .rightSpaceToView(self.containView, SJLayoutFrame(0))
    .heightIs(SJLayoutFrame(39));
    
    [self.containView addSubview:self.buttonItem_1];
    self.buttonItem_1.sd_layout
    .topSpaceToView(self.buttonItem_0, SJMargin)
    .leftSpaceToView(self.containView, SJLayoutFrame(0))
    .rightSpaceToView(self.containView, SJLayoutFrame(0))
    .heightIs(SJLayoutFrame(39));
    
    [self.containView addSubview:self.buttonItem_2];
    self.buttonItem_2.sd_layout
    .topSpaceToView(self.buttonItem_1, SJMargin)
    .leftSpaceToView(self.containView, SJLayoutFrame(0))
    .rightSpaceToView(self.containView, SJLayoutFrame(0))
    .heightIs(SJLayoutFrame(39));
    
    [self.containView addSubview:self.buttonItem_3];
    self.buttonItem_3.sd_layout
    .topSpaceToView(self.buttonItem_2, SJMargin)
    .leftSpaceToView(self.containView, SJLayoutFrame(0))
    .rightSpaceToView(self.containView, SJLayoutFrame(0))
    .heightIs(SJLayoutFrame(39));
    
    
    [self.containView addSubview:self.reportTextView];
    self.reportTextView.sd_layout
    .topSpaceToView(self.buttonItem_3, SJMargin)
    .leftSpaceToView(self.containView, SJLayoutFrame(0))
    .rightSpaceToView(self.containView, SJLayoutFrame(0))
    .heightIs(SJLayoutFrame(131));
    
    [self.containView addSubview:self.buttonItem_4];
    self.buttonItem_4.sd_layout
    .topSpaceToView(self.reportTextView, SJMargin)
    .leftSpaceToView(self.containView, SJLayoutFrame(0))
    .rightSpaceToView(self.containView, SJLayoutFrame(0))
    .heightIs(SJLayoutFrame(39));
    
}

- (void)setFrame:(CGRect)frame
{
    frame.size = CGSizeMake(SJLayoutFrame(269), SJLayoutFrame(361));
    [super setFrame:frame];
}


#pragma mark -- getter

- (UIView *)containView{
    
    if (!_containView) {
        
        _containView = [UIView new];
    }
    return _containView;
}


- (void)selectedItem:(UIButton *)button {
    
    NSInteger index = button.tag;
    
    if ([self.delegate respondsToSelector:@selector(reportView:didSelectItemAtIndex:button:)]) {
        
        [(id<SJSJReportViewDelegate>)self.delegate reportView:self didSelectItemAtIndex:index button:button];
    }
    
}

- (UIButton *)buttonItem_0 {
    
    if (!_buttonItem_0) {
        
        _buttonItem_0 = [UIButton buttonWithType:UIButtonTypeCustom];
        [_buttonItem_0 addTarget:self action:@selector(selectedItem:) forControlEvents:UIControlEventTouchUpInside];
        [_buttonItem_0 setTitle:@"发布垃圾广告" forState:UIControlStateNormal];
        _buttonItem_0.titleLabel.font = [UIFont systemFontOfSize:SJLayoutFrame(14)];
        _buttonItem_0.sd_cornerRadius = @(SJCornerRadius);
        _buttonItem_0.backgroundColor = SJColorHexString(@"#ffffff19");
        _buttonItem_0.layer.borderColor = [UIColor clearColor].CGColor;//边框颜色
        _buttonItem_0.layer.borderWidth = SJLayoutFrame(1);//边框宽度
        _buttonItem_0.tag = 1;
        
    }
    return _buttonItem_0;
}

- (UIButton *)buttonItem_1 {
    
    if (!_buttonItem_1) {
        
        _buttonItem_1 = [UIButton buttonWithType:UIButtonTypeCustom];
        [_buttonItem_1 addTarget:self action:@selector(selectedItem:) forControlEvents:UIControlEventTouchUpInside];
        [_buttonItem_1 setTitle:@"低俗色情" forState:UIControlStateNormal];
        _buttonItem_1.titleLabel.font = [UIFont systemFontOfSize:SJLayoutFrame(14)];
        _buttonItem_1.sd_cornerRadius = @(SJCornerRadius);
        _buttonItem_1.backgroundColor = SJColorHexString(@"#ffffff19");
        _buttonItem_1.layer.borderColor = [UIColor clearColor].CGColor;//边框颜色
        _buttonItem_1.layer.borderWidth = SJLayoutFrame(1);//边框宽度
        _buttonItem_1.tag = 2;
        
    }
    return _buttonItem_1;
}

- (UIButton *)buttonItem_2 {
    
    if (!_buttonItem_2) {
        
        _buttonItem_2 = [UIButton buttonWithType:UIButtonTypeCustom];
        [_buttonItem_2 addTarget:self action:@selector(selectedItem:) forControlEvents:UIControlEventTouchUpInside];
        [_buttonItem_2 setTitle:@"涉嫌违法犯罪" forState:UIControlStateNormal];
        _buttonItem_2.titleLabel.font = [UIFont systemFontOfSize:SJLayoutFrame(14)];
        _buttonItem_2.sd_cornerRadius = @(SJCornerRadius);
        _buttonItem_2.backgroundColor = SJColorHexString(@"#ffffff19");
        _buttonItem_2.layer.borderColor = [UIColor clearColor].CGColor;//边框颜色
        _buttonItem_2.layer.borderWidth = SJLayoutFrame(1);//边框宽度
        _buttonItem_2.tag = 4;
        
    }
    return _buttonItem_2;
}

- (UIButton *)buttonItem_3 {
    
    if (!_buttonItem_3) {
        
        _buttonItem_3 = [UIButton buttonWithType:UIButtonTypeCustom];
        [_buttonItem_3 addTarget:self action:@selector(selectedItem:) forControlEvents:UIControlEventTouchUpInside];
        [_buttonItem_3 setTitle:@"标题党 图片党 骗点击" forState:UIControlStateNormal];
        _buttonItem_3.titleLabel.font = [UIFont systemFontOfSize:SJLayoutFrame(14)];
        _buttonItem_3.sd_cornerRadius = @(SJCornerRadius);
        _buttonItem_3.backgroundColor = SJColorHexString(@"#ffffff19");
        _buttonItem_3.layer.borderColor = [UIColor clearColor].CGColor;//边框颜色
        _buttonItem_3.layer.borderWidth = SJLayoutFrame(1);//边框宽度
        _buttonItem_3.tag = 8;
        
    }
    return _buttonItem_3;
}

- (UIButton *)buttonItem_4 {
    
    if (!_buttonItem_4) {
        
        _buttonItem_4 = [UIButton buttonWithType:UIButtonTypeCustom];
        [_buttonItem_4 addTarget:self action:@selector(selectedItem:) forControlEvents:UIControlEventTouchUpInside];
        [_buttonItem_4 setTitle:@"提交" forState:UIControlStateNormal];
        
        [_buttonItem_4 setTitleColor:SJColorHexString(@"#99c7ff") forState:UIControlStateNormal];
        _buttonItem_4.titleLabel.font = [UIFont systemFontOfSize:SJLayoutFrame(14)];
        _buttonItem_4.sd_cornerRadius = @(SJCornerRadius);
        _buttonItem_4.backgroundColor = SJColorHexString(@"#ffffff19");
        _buttonItem_4.layer.borderColor = [UIColor clearColor].CGColor;//边框颜色
        _buttonItem_4.layer.borderWidth = SJLayoutFrame(1);//边框宽度
        _buttonItem_4.tag = 0;
        
    }
    return _buttonItem_4;
}

- (UITextView *)reportTextView {
    
    if (!_reportTextView) {
        
        _reportTextView = [UITextView new];
        _reportTextView.font = [UIFont systemFontOfSize:SJLayoutFrame(14)];
        _reportTextView.textColor = SJColorHexString(@"#ffffff");
        _reportTextView.backgroundColor = [UIColor clearColor];
        _reportTextView.textAlignment = NSTextAlignmentLeft;
        _reportTextView.sd_cornerRadius = @(SJCornerRadius);
        _reportTextView.backgroundColor = SJColorHexString(@"#ffffff19");
    }
    return _reportTextView;
}

@end

